home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / nwt2.exe / SELSERV.FRM < prev    next >
Text File  |  1993-07-22  |  4KB  |  144 lines

  1. VERSION 2.00
  2. Begin Form SelectServerForm 
  3.    Caption         =   "Attach to File Server"
  4.    ClientHeight    =   1710
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1485
  7.    ClientWidth     =   6585
  8.    Height          =   2115
  9.    Left            =   1035
  10.    LinkTopic       =   "Form2"
  11.    ScaleHeight     =   1710
  12.    ScaleWidth      =   6585
  13.    Top             =   1140
  14.    Width           =   6705
  15.    Begin TextBox PasswordBox 
  16.       Height          =   285
  17.       Left            =   1320
  18.       PasswordChar    =   "*"
  19.       TabIndex        =   4
  20.       Top             =   1200
  21.       Width           =   3495
  22.    End
  23.    Begin TextBox UserNameBox 
  24.       Height          =   285
  25.       Left            =   1320
  26.       TabIndex        =   3
  27.       Top             =   720
  28.       Width           =   3495
  29.    End
  30.    Begin ComboBox ServerNameBox 
  31.       Height          =   300
  32.       Left            =   1320
  33.       Sorted          =   -1  'True
  34.       TabIndex        =   2
  35.       Top             =   240
  36.       Width           =   3855
  37.    End
  38.    Begin CommandButton CancelButton 
  39.       Caption         =   "&Cancel"
  40.       Height          =   375
  41.       Left            =   5520
  42.       TabIndex        =   1
  43.       Top             =   720
  44.       Width           =   855
  45.    End
  46.    Begin CommandButton OKButton 
  47.       Caption         =   "&OK"
  48.       Default         =   -1  'True
  49.       Height          =   375
  50.       Left            =   5520
  51.       TabIndex        =   0
  52.       Top             =   240
  53.       Width           =   855
  54.    End
  55.    Begin Label Label3 
  56.       Alignment       =   1  'Right Justify
  57.       Caption         =   "Password:"
  58.       Height          =   255
  59.       Left            =   120
  60.       TabIndex        =   7
  61.       Top             =   1200
  62.       Width           =   1095
  63.    End
  64.    Begin Label Label2 
  65.       Alignment       =   1  'Right Justify
  66.       Caption         =   "User:"
  67.       Height          =   255
  68.       Left            =   120
  69.       TabIndex        =   6
  70.       Top             =   720
  71.       Width           =   1095
  72.    End
  73.    Begin Label Label1 
  74.       Alignment       =   1  'Right Justify
  75.       Caption         =   "Server:"
  76.       Height          =   255
  77.       Left            =   120
  78.       TabIndex        =   5
  79.       Top             =   240
  80.       Width           =   1095
  81.    End
  82. End
  83.  
  84. Sub CancelButton_Click ()
  85.     End
  86. End Sub
  87.  
  88. Sub Form_Load ()
  89.     ScanForServers
  90.  
  91.     'save the preferred connection ID, so we can restore it later
  92.     originalPreferredServer% = GetPreferredConnectionID()
  93.  
  94.     userName$ = GetDefaultUserName()
  95.     If (Len(userName$) = 0) Then
  96.         MsgBox "You are not logged in to a NetWare server", MB_OK, "Error"
  97.         End
  98.     Else
  99.         UserNameBox.Text = userName$
  100.     End If
  101.  
  102.     'ServerInfoForm.UserNameLabel = userName$
  103. End Sub
  104.  
  105. Function GetDefaultUserName () As String
  106. 'Returns a null string if the user is not logged in to any
  107. '  NetWare file servers; otherwise returns the user's
  108. '  username on the default file server
  109.  
  110.     Dim loginTime As DATE_AND_TIME
  111.  
  112.     connectionNumber& = GetConnectionNumber()
  113.     userName$ = String$(48, 0)
  114.     cCode% = GetConnectionInformation(connectionNumber&, userName$, objectType%, objectID&, loginTime)
  115.     If (cCode% = SUCCESSFUL) Then
  116.         GetDefaultUserName = userName$
  117.     Else
  118.         GetDefaultUserName = ""
  119.     End If
  120. End Function
  121.  
  122. Sub OKButton_Click ()
  123.     userName$ = UCase$(UserNameBox.Text)
  124.     serverName$ = UCase$(ServerNameBox.Text)
  125.     password$ = UCase$(PasswordBox.Text)
  126.     ServerInfoForm.Show
  127. End Sub
  128.  
  129. Sub ScanForServers ()
  130.     oID& = -1   'initialize object ID to -1 for first call to ScanBinderyObject
  131.     Do
  132.         serverName$ = String$(48, 0)
  133.         cCode% = ScanBinderyObject("*", OT_FILE_SERVER, oID&, serverName$, oType%, oHasProps%, oFlag%, oSecurity%)
  134.         If (cCode% = SUCCESSFUL) Then
  135.             
  136.             'take all characters of object name up to terminating null
  137.             serverName$ = Left$(serverName$, InStr(serverName$, Chr$(0)) - 1)
  138.  
  139.             ServerNameBox.AddItem serverName$
  140.         End If
  141.     Loop Until cCode%
  142. End Sub
  143.  
  144.